#include <QCoreApplication>
#include <QNetworkConfigurationManager>
#include <QNetworkSession>
#include <QDebug>


 penNetworkConnection()
{
    QNetworkConfigurationManager manager;
    const bool canStartIAP = (manager.capabilities() &
    QNetworkConfigurationManager::CanStartAndStopInterfaces); // Is there
    // default access point, use it
    QNetworkConfiguration cfg = manager.defaultConfiguration();
    if (!cfg.isValid() || (!canStartIAP && cfg.state() !=
    QNetworkConfiguration::Active))
    {
        qDebug()<<"No Access Point found.";
        //QMessageBox::information(this, tr("Network"), tr("No Access Point found."));
        return false;
    }
    QNetworkSession* session = new QNetworkSession(cfg, this);
    session->open();
    return session->waitForOpened(-1);
}

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    return a.exec();
}
